/*
 * @Description:
 * @version:
 * @Author: sunqian_sr
 * @Date: 2022-11-18 15:33:43
 * @LastEditors: Andy
 * @LastEditTime: 2023-02-22 14:52:46
 */

import { createPinia } from 'pinia'
import workflow from '@package/components/src/workflow/pinia/workflow'
import settings from './setting'
import cachedView from './cachedView'

const pinia = createPinia()
export default pinia

const context = import.meta.glob('../../modules/**/pinia/*.js', { eager: true })
let modulesPinias = {
  settings,
  cachedView,
  workflow
}
Object.keys(context).forEach((key) => {
  const files = key
  const [path, module, base, fileName] = files.replace(/(\..\/|\/module\/|\.js)/g, '').split('/')
  const tempObj = {}
  tempObj[fileName] = context[key].default
  modulesPinias = { ...modulesPinias, ...tempObj }
})

export const pinias = {
  ...modulesPinias
}
